package com.itheima.volitale.送冰淇淋;

public class Test {
    public static void main(String[] args) {
            MyAtomThread atom=new MyAtomThread();

        for (int i = 0; i < 100; i++) {
            new Thread(atom).start();
        }
    }
}

class MyAtomThread implements Runnable{
    private int count=0;        //送冰淇淋的数量

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            //从共享数据中读取数据到本线程栈中
            //修改本线程栈中变量副本的值
            //会把本线程栈中变量副本的值赋值给共享数据
            synchronized ("abc") {
            count++;
                System.out.println("已经送了"+count+"个冰淇淋");
            }
        }
    }
}